package com.tomshushu.doc.freedoc.modular.directory.controller;

import com.tomshushu.doc.freedoc.core.model.response.ResponseData;
import com.tomshushu.doc.freedoc.core.model.response.SuccessResponseData;
import com.tomshushu.doc.freedoc.modular.directory.model.param.AddDirectoryParam;
import com.tomshushu.doc.freedoc.modular.directory.model.param.DeleteDirectoryParam;
import com.tomshushu.doc.freedoc.modular.directory.model.param.GetChildDirectoryParam;
import com.tomshushu.doc.freedoc.modular.directory.model.param.ReNameParam;
import com.tomshushu.doc.freedoc.modular.directory.service.DirectoryService;
import com.tomshushu.doc.freedoc.modular.doc.model.param.DeleteDocParam;
import com.tomshushu.doc.freedoc.modular.project.model.param.AddProjectParam;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description:
 * @author: zhouhong
 * @date: 2025-06-11 12:20
 * @version: 1.0
 */
@RestController
@RequestMapping("/doc/directory")
public class DirectoryController {
    @Resource
    private DirectoryService directoryService;

    /**
     * 添加目录
     *
     * @param param
     * @return
     */
    @PostMapping("/addDirectory")
    public ResponseData addDirectory(@RequestBody AddDirectoryParam param) {
        return new SuccessResponseData(directoryService.addDirectory(param));
    }

    @PostMapping("/renameDirectory")
    public ResponseData rename(@RequestBody ReNameParam param) {
        directoryService.rename(param);
        return new SuccessResponseData();
    }

    /**
     * 获取子目录和文档列表
     *
     * @param param
     * @return
     */
    @PostMapping("/getChildDirectoryAndDocList")
    public ResponseData getChildDirectoryAndDocList(@RequestBody GetChildDirectoryParam param) {
        return new SuccessResponseData(directoryService.getChildDirectoryAndDocList(param));
    }

    @PostMapping("/deleteDirectory")
    public ResponseData deleteDirectory(@RequestBody DeleteDirectoryParam param) {
        directoryService.deleteDirectory(param);
        return new SuccessResponseData();
    }

}